package com.edu.app.mapper.linkmappers;

import com.edu.app.bean.core.SysCustomerTrace;
import com.edu.app.bean.virtualbean.trace.TraceBean;
import com.edu.app.util.AppBaseMapper;

import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public interface SysCustomerTraceMapper extends AppBaseMapper<SysCustomerTrace> {
    @Select("DELETE FROM S_CUSTOMER_TRACE WHERE customer_id = #{id}")
    List<SysCustomerTrace> deleteTraceByCustomerId(Integer id);

    @Select("select t1.id, t3.nickname as name, t1.create_time as time, " +
            "t1.content,t4.file_url,t4.file_mime_type,t4.file_size from s_customer_trace t1 " +
            "inner join s_customer t2 on t1.customer_id = t2.id " +
            "inner join s_user t3 on t3.username = t1.create_by " +
            "left join s_file t4 on t4.id = t1.file_id " +
            "where t1.customer_id = #{id} order by time desc")
    List<TraceBean> getCustomerTraceById(Integer id);
}
